package fr.maistre.TestMarché;

import fr.maistre.SystemeMarché.Implementation.ReferenceMarket;
import fr.maistre.SystemeMarché.Implementation.SimpleMarket;
import fr.maistre.SystemeMarché.Interface.MarketEventManager;
import fr.maistre.SystemeMarché.Vue.MarketToPNG;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		// parametrage marché
		MarketEventManager marché = new SimpleMarket("France", 60000000.0,
				3500.0, 0.25,
				0.1, 0.35, 10000.0);

		ReferenceMarket referenceMarketVigne = new ReferenceMarket(0.000002,
				10000.0, 1, 10000.0, 14870.0, 38905.83, 34394.97);
		marché.setReferenceMarket(MarketableExemples.VIGNE,
				referenceMarketVigne);

		ReferenceMarket referenceMarketB = new ReferenceMarket(0.0001, 0, 2000,
				7.44, 2.05, 12839012.34, 24309317.72);
		referenceMarketB.addInfrastructure(MarketableExemples.VIGNE, 0.005);
		marché.setReferenceMarket(MarketableExemples.RAISIN, referenceMarketB);

		ReferenceMarket referenceMarketC = new ReferenceMarket(0.0002, 1.98,
				2000, 1500.0, 5.85, 449944041.97, 660698721.08);
		referenceMarketC.addMatierePremiere(MarketableExemples.RAISIN, 1);
		marché.setReferenceMarket(MarketableExemples.CRU_NORMAL,
				referenceMarketC);

		ReferenceMarket referenceMarketCruC = new ReferenceMarket(0.00002,
				1.98, 2000, 2000.0, 10.5, 449944041.97, 660698721.08);
		referenceMarketCruC.addMatierePremiere(MarketableExemples.RAISIN, 3);
		marché.setReferenceMarket(MarketableExemples.CRU_EXELENT,
				referenceMarketCruC);

		long start = System.currentTimeMillis();
		System.out.println("Debut de la simulation");


		marché.simulateMarketWithEvent(10);

		long duree = System.currentTimeMillis() - start;

		// affichage valeurs finales
		for (String ref : marché.getReferences().keySet()) {
			System.out.println(marché.getReferences().get(ref).prix
					+ " valeur finale de " + ref);
		}

		System.out.println("Executé en moin de : " + ((duree / 1000) + 1)
				+ " seconde(s)");
		System.out.println("Generation Graphiques...");
		// Creation des graphiques
		MarketToPNG marketToPNG = new MarketToPNG(marché);
		System.out.println("Fin de generation des graphiques");
	}

}
